//订阅者
export default class Subject {
    constructor() {
        this.state = true
        this.observers = []
    }
    getState() {
        return this.state
    }
    setState(state) {
        this.state = state
        this.allObservers();
    }
    allObservers() {
        this.observers.forEach(observersItem => { observersItem.update() })
    }
    attach(observers) {
        this.observers.push(observers)
    }
}
